/* eslint-disable no-redeclare */
// 一、
function fn1(a, b) {
  // AO = {
  //   b: undefined,
  //   a: (undefined) => function a() {},
  // };
  console.log(a); // function a() {}
  console.log(b); // undefined
  var b = 234;
  console.log(b); // 234
  a = 123;
  console.log(a); // 123

  function a() {}
  var a;
  b = 234;
  var b = function () {};
  console.log(a); // 123
  console.log(b); // function () {}
}
fn1(1);

// 二、
a = 100;

function fn2(e) {
  /*
        AO = {
          b: undefined,
          c: undefined,
          a: undefined,
          e: undefined => 1(实参),
        };
        */
  function e() {}
  arguments[0] = 2;
  console.log(e); // function e() {}
  if (a) {
    var b = 123;
  }
  var c;
  a = 10;
  var a;
  console.log(b);
  f = 123;
  console.log(c);
  console.log(a);
}
var a;
fn2(1);
console.log(a); // 100
console.log(f); // 123

// 三、
global = 100;
function fn3(global) {
  console.log(global);
  global = 200;
  console.log(global);
  var global = 300;
}

fn3(global);
var global;

// 四、
function fn4(a) {
  var d;
  var c;
  b = 10;
  var a;
  console.log(a);
  a = 123;

  function a() {}
  console.log(a);
  var b;
  console.log(b);

  function c() {}
  console.log(c);
  console.log(d);
  d = 100;
  console.log(d);
}
fn4(5);

// 五、
let obj = {
  a: 110,
  fn: function (a) {
    console.log(a);
    a = 10;
    console.log(a);
  },
};

obj.fn(obj.a);

// 六、
// 1,1,2,3,5,8,13,.....
// 求第n项的和, 例子: 求第三项的和, 1 + 1 + 2

// 七、
// 要求输入id 返回数据对象
// 例如: 输入id=111, 返回{id: 111,gname: '海尔冰箱'}
var data = [
  {
    id: 1,
    name: '家电',
    goods: [
      {
        id: 11,
        gname: '冰箱',
        goods: [
          {
            id: 111,
            gname: '海尔冰箱',
          },
          {
            id: 112,
            gname: '小天鹅冰箱',
          },
        ],
      },
      {
        id: 12,
        gname: '洗衣机',
      },
    ],
  },
  {
    id: 2,
    name: '服饰',
  },
];
